# -*- coding: utf-8 -*-
# appengine imports
from google.appengine.ext import db
from google.appengine.api import memcache

#python imports
import hashlib

#local imports
from baserequesthandler import BaseRequestHandler, BesucherHandler
from models import Policy
from db_key import get_key_name


class Handler(BaseRequestHandler):
  def get(self):
    akey = self.request.get('akey')
    gewonnen = self.request.get('gewonnen')
    verloren = self.request.get('verloren')
    key_name = get_key_name(prefix='policy', akey=akey)
    p = Policy.get_by_key_name(key_name)
    if p is None:
      p = Policy.get_or_insert(key_name,akey=akey, gewonnen=gewonnen,verloren=verloren)
      p.put()
    else: # alte Werte ueberschreiben
      p.akey = akey
      p.gewonnen = gewonnen
      p.verloren = verloren
      p.put()
    self.response.out.write('policy neu erstellt')
    
